<template>
  <div>
    <h1 ref="sfRef">ref获取元素</h1>
  </div>
</template>

<script setup>
import { onMounted, ref } from 'vue';

/**
 *  0 导入ref
 *  1.创建 ref => const hRef = ref(null)

    2.模板中建立关联 => <h1 ref="hRef">我是标题</h1>

    3.使用 => hRef.value
 */
const sfRef = ref(null)
onMounted(() => {
  console.log(sfRef.value);
  sfRef.value.style.color = 'teal'
})
</script>

<style lang="scss" scoped>

</style>